f = lambda: map(int, input().split())
n, m = f()
t = list(f())
s = [0] * 301
d = s[:]
for i in t: d[i] += 1
for i in t * min(m, 2 * n): s[i] = max(s[:i + 1]) + 1
print(max(s) + max((m - n * 2) * max(d), 0))
#include <bits/stdc++.h>
using namespace std;
const int mxN = 300;
int bit[mxN], cnt[mxN];
void update(int idx, int x) {
int s = 0;
for (; idx < mxN; idx = (idx | (idx+1))) {
bit[idx] = max(bit[idx], x);
}
}
int mx(int idx) {
int s = 0;
for (; idx >= 0; idx = (idx & (idx + 1)) - 1) {
s = max(s, bit[idx]);
}
return s;
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
int n, t;
cin >> n >> t;
const int d = n*min(n+1, t); // mozda iz n u n+1??
int a[d];
for (int i = 0; i < n; ++i) {
cin >> a[i];
a[i]--;
cnt[a[i]]++;
}
for (int i = n; i < d; ++i) {
a[i] = a[i-n];
}
int dp[d];
for (int i = 0; i < d; ++i) {
dp[i] = mx(a[i])+1;
update(a[i], dp[i]);
}
int x = 0;
for (int i = 0; i < 300; ++i) {
if (cnt[x] < cnt[i]) {
x = i;
}
}
long long ans = mx(300);
if (t > n+1) {
ans+= (t-n-1)*cnt[x];
}
cout << ans << '\n';
}
448A - Rewards | 1622A - Construct a Rectangle |
1620A - Equal or Not Equal | 1517A - Sum of 2050 |
620A - Professor GukiZ's Robot | 1342A - Road To Zero |
1520A - Do Not Be Distracted | 352A - Jeff and Digits |
1327A - Sum of Odd Integers | 1276A - As Simple as One and Two |
812C - Sagheer and Nubian Market | 272A - Dima and Friends |
1352C - K-th Not Divisible by n | 545C - Woodcutters |
1528B - Kavi on Pairing Duty | 339B - Xenia and Ringroad |
189A - Cut Ribbon | 1182A - Filling Shapes |
82A - Double Cola | 45A - Codecraft III |
1242A - Tile Painting | 1663E - Are You Safe |
1663D - Is it rated - 3 | 1311A - Add Odd or Subtract Even |
977F - Consecutive Subsequence | 939A - Love Triangle |
755A - PolandBall and Hypothesis | 760B - Frodo and pillows |
1006A - Adjacent Replacements | 1195C - Basketball Exercise |